/**
 * Created by 功振 on 2016/2/19.
 */
angular.module('Portal').factory('userInfoService', ["$http", function ($http) {
    var userInfoService = {
        isUserExisted: function (username) {
            var userBasicInfoURL = "/userBasicInfo/isExists?user=" + username;
            return $http.get(userBasicInfoURL, username);
        },
        isPhoneExisted: function (phoneNumber) {
            var userBasicInfoURL = "/userBasicInfo/isExists?phone=" + phoneNumber;
            return $http.get(userBasicInfoURL, phoneNumber);
        },
        triggerIdentifyingCode : function(phoneNumber) {
            return $http.get('/userBasicInfo/triggerIdentifyingCode?phone=' + phoneNumber);
        },
        createNewUser: function (userInfo) {
           //here may be cost long when jenkins is out of service of someting else
           // return $http.post('/userBasicInfo/createUser', userInfo,{timeout:10000});
            return $http.post('/userBasicInfo/createUser', userInfo );
        },
        //Added by Michael
        getUserInfo:function(username){
            var userBasicInfoURL = "/userBasicInfo/getUserInfo?user=" + username;
            return $http.get(userBasicInfoURL, username);
        },

        getIdentifyingCode:function(phoneNumber) {
            return $http.get('/userBasicInfo/getIdentifyingCode?phone=' + phoneNumber);
        },
        resetPwd:function(userInfo)
        {
            return $http.post('/userBasicInfo/resetPwd', userInfo);
        },
        //
        updateUser: function (userInfo) {
            return $http.post('/userBasicInfo/updateUser', userInfo);
        },
        authenticateUser: function (userLoginInfo) {
            var userBasicInfoURL = "/userBasicInfo/authenticate";
            return $http.post(userBasicInfoURL, userLoginInfo);
        },
    }
    return userInfoService;
}]);